package com.supply.dl.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.supply.dl.R;
import com.supply.dl.bean.BaseItemBean;
import com.supply.dl.utils.CommonNormalAdapterUtil;
import com.supply.dl.utils.RecyclerViewUtil;
import com.supply.dl.utils.Utils;
import com.supply.dl.utils.utils.ToastUtil;
import com.supply.dl.view.MaxRecyclerView;
import com.supply.dl.widget.LoadTipFailedLayout;
import com.supply.dl.widget.adapter.CommonNormalAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by ${qianzhihe} on 2018/5/7.
 * 库位选择
 */

public class ReservoirPositionChooseActivity extends BaseActivity{

    /**
     * 加载框
     */
    @BindView(R.id.reservoir_position_choose_main_loadView)
    LoadTipFailedLayout loadTipFailedLayout;

    @BindView(R.id.reservoir_position_choose_main_recyclerView)
    MaxRecyclerView mRecyclerView;
    CommonNormalAdapter mAdapter;
    int mAdapterFlag;
    List<BaseItemBean> itemList;

    int activityFlag;//UI标识，用于区别跳转前的Activity

    @BindView(R.id.reservoir_position_choose_main_filterBtnLayout)
    LinearLayout filterBtnLayout;//筛选按钮
    @BindView(R.id.reservoir_position_choose_main_filterContentLayout)
    LinearLayout filterContentLayout;//筛选

    @BindView(R.id.reservoir_position_choose_main_resettingBtnTv)
    TextView resettingBtnTv;//重置按钮
    @BindView(R.id.reservoir_position_choose_main_sureBtnTv)
    TextView sureBtnTv;//确定按钮

    @Override
    protected int getLayoutResource() {
        return R.layout.reservoir_position_choose_main;
    }

    @Override
    protected void initView() {
        super.initView();
        showLeftBack();
        setTitleShow(getResourcesString(R.string.reservoirPositionChoose));
    }

    @Override
    protected void initLoadingView() {
        super.initLoadingView();
        loadTipFailedLayout.setRestartOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            }
        });
    }

    @Override
    protected void initListener() {
        super.initListener();
        setRightHomeClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ToastUtil.showToast(ReservoirPositionChooseActivity.this, "home");
            }
        });

        setRightScanClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ToastUtil.showToast(ReservoirPositionChooseActivity.this, "scan");
                Utils.startScanActivity(ReservoirPositionChooseActivity.this);
            }
        });
        filterBtnLayout.setOnClickListener(this);
        resettingBtnTv.setOnClickListener(this);
        sureBtnTv.setOnClickListener(this);
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        super.initData(savedInstanceState);
        itemList=new ArrayList<>();
        mAdapterFlag= CommonNormalAdapter.FLAG_RESERVOIR_POSITION_CHOOSE_MAIN;
    }

    @Override
    protected void initRecyclerView() {
        super.initRecyclerView();
        RecyclerViewUtil.initLinearLayoutHorizontal(this, mRecyclerView);
        mAdapter= CommonNormalAdapterUtil.initCommonNormalAdapter(R.layout.reservoir_position_choose_item, itemList, mAdapterFlag);
        mAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {

            }
        });
        mRecyclerView.setAdapter(mAdapter);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()){
            case R.id.reservoir_position_choose_main_filterBtnLayout:
                mRecyclerView.setVisibility(View.GONE);
                filterContentLayout.setVisibility(View.VISIBLE);
                break;
            case R.id.reservoir_position_choose_main_resettingBtnTv:
                break;
            case R.id.reservoir_position_choose_main_sureBtnTv:
                filterContentLayout.setVisibility(View.GONE);
                mRecyclerView.setVisibility(View.VISIBLE);
                break;
        }
    }
}
